<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use app\portal\model\DiaryModel;
use cmf\controller\HomeBaseController;

class DiaryController extends HomeBaseController
{
    /**
     * 页面管理
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $year = DiaryModel::query()
            ->field('year')
            ->where('status', '=',1)
            ->order('year desc')
            ->group('year')
            ->column('year');

        $msg = DiaryModel::query()
            ->where('status', '=', 1)
            ->order('create_time desc')
            ->limit(100)
            ->select()
            ->toArray();

        $this->assign('year', $year);
        $this->assign('msg', $msg);
        return $this->fetch("/diary");
    }

}
